<!DOCTYPE html>
<html lang="zh_CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <title>角色列表</title>
    <th:block th:include="~{common/common::commonHead}"/>
</head>
<body>
<div class="page-body">
    <div class="panel panel-primary shiny">
        <div class="panel-heading bg-blue">
            角色列表
        </div>
        <div class="widget-body grid-table">
            <div class="toolbar">
                <div class="fl-left">
                    <button data-menu-id="050401" data-click="add('account/roleAdd.html','roleList')" class="btn btn-blue shiny">新增角色</button>
                    <button data-menu-id="050402" data-click="del('roleList','role/delRole', false)" class="btn btn-danger shiny">刪除角色</button>
                    <button data-menu-id="050403" data-click="setPower()" class="btn btn-warning shiny">角色权限</button>
                </div>
                <div class="toolbar-right">
                    <div class="fl-right">
                        <div class="btn-group" role="group">
                            <button data-click="toggleFilter()" class="btn btn-default text-center">
                                <i class="fa fa-filter fa-fw"></i>
                            </button>
                            <button data-click="refresh('roleList')" class="btn btn-default">
                                <i class="fa fa-refresh fa-fw"></i>
                            </button>
                            <button data-click="download('roleList')" class="btn btn-default">
                                <i class="fa fa-download fa-fw"></i>
                            </button>
                        </div>
                    </div>
                </div>
            </div>
            <div id="roleList"></div>
            <form class="filter search-content form-horizontal" data-width="650" role="form">
                <!--<div class="col-xs-6">-->
                    <!--<div class="form-group">-->
                        <!--<label class="col-xs-4 control-label">组织编号：</label>-->
                        <!--<div class="col-xs-8">-->
                            <!--<div class="iconic-input right">-->
                                <!--<input name="orgId" type="text" class="form-control spinner">-->
                            <!--</div>-->
                        <!--</div>-->
                    <!--</div>-->
                <!--</div>-->
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="col-xs-4 control-label">角色名称：</label>
                        <div class="col-xs-8">
                            <div class="iconic-input right">
                                <input name="roleName" type="text" class="form-control spinner" placeholder="角色名称">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="col-xs-4 control-label">所属组织：</label>
                        <div class="col-xs-8">
                            <select name="orgId" class="form-control spinner" data-url="org/listOrg" data-value-field="id" data-text-field="orgName" data-value="-1">
                                <option value="-1">全部</option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="col-xs-6">
                    <div class="form-group">
                        <label class="col-xs-4 control-label">角色状态：</label>
                        <div class="col-xs-8">
                            <select name="roleStatus" class="form-control spinner" data-url="role/listRoleStatus" data-value-field="id" data-text-field="text" data-value="-1">
                                <option value="-1">全部</option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="col-xs-12">
                    <button type="button" data-click="hideFilter()" class="btn btn-default pull-right">取消</button>
                    <button type="button" data-click="submitFilter('roleList')" class="btn btn-blue pull-right">确定</button>
                </div>
            </form>
        </div>
    </div>
</div>
</body>
</html>
<script>
    $(function () {
        $("#roleList").gridTable({
            url: "role/pageRole",
            columns: [
                {title: "角色编号", field: "id"},
                {title: "角色名称", field: "roleName"},
                {title: "角色状态", field: "roleStatusStr"},
                {title: "所属组织", field: "orgName"},
                {title: "创建时间", field: "createTime"},
                {title: "更新时间", field: "updateTime"}
            ],
            idField: "id",
            infoUrl: "account/roleInfo.html",
            editUrl: "account/roleEdit.html",
            delUrl: "role/delRole"
        });
    });
    function setPower() {
        var gridTable = $$selection.get("gridTable", "roleList");
        var selectedRows = gridTable.getSelectedRows();
        if (selectedRows.length === 0) {
            $.error("请选择一个角色进行操作");
            return;
        }
        if (selectedRows.length > 1) {
            $.error("每次只能操作一条数据");
            return;
        }
        var roleId = selectedRows[0].getData().id;
        $.openIframeDialog({
            url: "account/rolePower.html",
            param: {roleId: roleId},
            afterSubmit: function () {
                $.success("权限配置成功");
            }
        });
    }
</script>